package com.xrz.sxm.aj.activity;

import android.text.TextPaint;
import android.widget.LinearLayout;
import android.widget.LinearLayout.LayoutParams;
import android.widget.ScrollView;
import android.widget.TextView;

import com.lidroid.xutils.view.annotation.ViewInject;
import com.xrz.sxm.aj.base.BaseAct;
import com.xrz.sxm.aj.entity_tab.Jlb;
import com.xrz.sxm.aj.utils.DisplayUtil;
import com.xrz.sxm.aj.utils.ScreenUtil;
import com.xrz.sxm.aj.utils.Utils;
import com.xrz.sxm.aj.view.ViewArea;

/**
 * @author 辛汝州 2014-12-17
 */
public class Act_JingMai extends BaseAct {

	@ViewInject(R.id.tv_content)
	private TextView tv_content;

	@ViewInject(R.id.jingmai_sv)
	private ScrollView m_ScrollView;

	private int content_hight;

	@ViewInject(R.id.touchview)
	private LinearLayout m_ZoomLayout;

	private Jlb m_JingluoEntity;

	@Override
	protected int setView() {
		return R.layout.layout_jingmai;
	}

	@Override
	protected void init() {
		TextPaint paint = tv_content.getPaint();
		float len = paint.measureText(tv_content.getText().toString());
		content_hight = (((int) len / ScreenUtil.getInstant().getDisWidth(ctx)) + 1)
				* DisplayUtil.sp2px(ctx, 16);
		LayoutParams params = (LayoutParams) m_ScrollView.getLayoutParams();
		params.height = Math.min(content_hight, ScreenUtil.getInstant()
				.getDisHight(ctx) / 3);
		m_ScrollView.setLayoutParams(params);
		if (m_JingluoEntity != null)
			tv_content.setText(m_JingluoEntity.ms);


		int res = R.mipmap.ic_launcher;
		int a = Utils.getImageByPicName(m_JingluoEntity.jldm);
		if (a != 0) {
			res = a;
		}
		ViewArea viewArea = new ViewArea(ctx, res);
		m_ZoomLayout.addView(viewArea, new LayoutParams(
				LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT));

	}

	@Override
	protected String setTopTitle() {
		m_JingluoEntity =  (Jlb) getIntent().getSerializableExtra(
				"data");
		if(m_JingluoEntity == null)
			return "";
		return m_JingluoEntity.jlmc;
	}

}
